package com.shop.controller;


import com.alipay.api.internal.util.AlipaySignature;
import com.shop.common.result.Result;
import com.shop.common.result.util.ResultModel;
import com.shop.service.SellerCommodityExtendService;
import com.shop.vo.seller.AddSellerCommodityExtendVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 卖家商品扩展表 前端控制器
 * </p>
 *
 * @author 靳 旺
 * @since 2021-03-17
 */
@Slf4j
@RestController
@Api(tags = "卖家商品扩展前端控制器")
@RequestMapping("/seller-commodity-extend-do")
public class SellerCommodityExtendController {


    @Autowired
    private SellerCommodityExtendService sellerCommodityExtendService;


    @PostMapping("addSellerCommodityExtend")
    @ApiOperation(value = "商家进货",notes = "靳旺")
    public ResultModel addSellerCommodityExtend(@RequestBody List<AddSellerCommodityExtendVo> addSellerCommodityExtendVoList)throws Exception{
        return sellerCommodityExtendService.addSellerCommodityExtendVo(addSellerCommodityExtendVoList);
    }


    @RequestMapping(value = "/paySuccessMessage")
    public ResultModel paySuccessMessage(HttpServletRequest request, HttpServletRequest response) throws Exception {
        //商户订单号
        String out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"),"UTF-8");
        //支付宝交易号
        String trade_no = new String(request.getParameter("trade_no").getBytes("ISO-8859-1"),"UTF-8");
        //交易状态
        String trade_status = new String(request.getParameter("trade_status").getBytes("ISO-8859-1"),"UTF-8");

        log.info("---------------------- > 商户订单号:{},支付宝交易号 :{},交易状态 :{}",out_trade_no,trade_no,trade_status);
        return sellerCommodityExtendService.paySuccessMessage(out_trade_no,trade_no,trade_status);
    }


}
